import request from '@u/request'
import { HttpMethod } from '@u/http'

// 查询角色列表
export function listRole(query) {
  return request({
    url: `/sys/role/list`,
    method: HttpMethod.GET,
    params: query
  })
}

// 查询角色详细
export function getRole(roleId) {
  return request({
    url: '/sys/role/' + roleId,
    method: HttpMethod.GET
  })
}

// 新增角色
export function addRole(data) {
  return request({
    url: '/sys/role',
    method: HttpMethod.POST,
    data: data
  })
}

// 修改角色
export function updateRole(data) {
  return request({
    url: '/sys/role',
    method: HttpMethod.PUT,
    data: data
  })
}

// 角色数据权限
export function updateDataScope(data) {
  return request({
    url: '/sys/role/updateDataScope',
    method: HttpMethod.PUT,
    data: data
  })
}

// 角色状态修改
export function changeRoleStatus(roleId, status) {
  return request({
    url: `/sys/role/changeStatus/${roleId}/${status}`,
    method: HttpMethod.PUT
  })
}

// 删除角色
export function delRole(roleId) {
  return request({
    url: '/sys/role/' + roleId,
    method: 'delete'
  })
}
